home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c
- Subject: Re: Floating point calculation order
- Date: Tue, 23 Jan 1996 11:32:31 GMT
- Organization: Netcom
- Message-ID: <3104c6d9.134061184@nntp.ix.netcom.com>
- References: <m0tedv8-0002eqC@sice.nsk.su>
- NNTP-Posting-Host: ix-dc6-08.ix.netcom.com
- X-NETCOM-Date: Tue Jan 23 3:31:59 AM PST 1996
- X-Newsreader: Forte Agent .99c/16.141
-
- "Pavel A. Zemtsov" <PZEM@sice.nsk.su> wrote:
-
- >
- > Having declaration
- >
- > double x, p, q, r;
- >
- > my compiler (cc on SCO 3.2) calculated following expression:
- >
- > x = p * q / r;
- >
- > as p * (q/r); (I mean, it divided first, than multiplied). That
- > resulted in precision loss.
- >
- > Is this legal behavior?
-
- Not in ANSI C, but it was legal in K&R. If memory serves, it was not
- made illegal until very late in the standardizattion process so if
- your compiler was written before the standard was finalized it may not
- adhere to this.
-
- Michael M Rubenstein
-